Skip to content

Commit 58751ca

Browse files
authored
Add tests for Atomics.pause (#4147)
* Add tests for Atomics.pause * Address review
1 parent 830c521 commit 58751ca

File tree

8 files changed

+154
-0
lines changed

8 files changed

+154
-0
lines changed

features.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ source-phase-imports-module-source
106106
# https://github.com/tc39/proposal-arraybuffer-base64
107107
uint8array-base64
108108

109+
# Atomics.pause
110+
# https://github.com/tc39/proposal-atomics-microwait
111+
Atomics.pause
112+
109113
## Standard language features
110114
#
111115
# Language features that have been included in a published version of the
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2024 the V8 project authors. All rights reserved.
2+
// This code is governed by the license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-atomics.pause
6+
description: Testing descriptor property of Atomics.pause
7+
includes: [propertyHelper.js]
8+
features: [Atomics.pause]
9+
---*/
10+
11+
verifyProperty(Atomics, 'pause', {
12+
enumerable: false,
13+
writable: true,
14+
configurable: true,
15+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2024 the V8 project authors. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-atomics.pause
6+
description: Atomics.pause.length is 0.
7+
includes: [propertyHelper.js]
8+
features: [Atomics.pause]
9+
---*/
10+
11+
verifyProperty(Atomics.pause, 'length', {
12+
value: 0,
13+
enumerable: false,
14+
writable: false,
15+
configurable: true,
16+
});

test/built-ins/Atomics/pause/name.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2024 the V8 project authors. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-atomics.pause
6+
description: Atomics.pause.name is "pause".
7+
includes: [propertyHelper.js]
8+
features: [Atomics.pause]
9+
---*/
10+
11+
verifyProperty(Atomics.pause, 'name', {
12+
value: 'pause',
13+
enumerable: false,
14+
writable: false,
15+
configurable: true,
16+
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2024 the V8 project authors. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-atomics.pause
6+
description: Atomics.pause throws on negative argument values
7+
features: [Atomics.pause]
8+
---*/
9+
10+
const values = [
11+
-1,
12+
Number.MIN_SAFE_INTEGER,
13+
Number.MIN_SAFE_INTEGER - 1
14+
];
15+
16+
for (const v of values) {
17+
assert.throws(RangeError, () => { Atomics.pause(v); },
18+
`${v} is an illegal iterationNumber`);
19+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright (C) 2024 the V8 project authors. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-atomics.pause
6+
description: Atomics.pause throws on non-integral Number argument values
7+
features: [Atomics.pause]
8+
---*/
9+
10+
const values = [
11+
true,
12+
false,
13+
null,
14+
42.42,
15+
-42.42,
16+
NaN,
17+
Infinity,
18+
Symbol("foo"),
19+
"bar",
20+
"42",
21+
/baz/,
22+
42n,
23+
{},
24+
[],
25+
function() {},
26+
{ valueOf() { return 42; } }
27+
];
28+
29+
for (const v of values) {
30+
assert.throws(TypeError, () => { Atomics.pause(v); },
31+
`${v ? v.toString() : v} is an illegal iterationNumber`);
32+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright 2024 the V8 project authors. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-ecmascript-standard-built-in-objects
6+
description: Atomics.pause does not implement [[Construct]], is not new-able
7+
info: |
8+
ECMAScript Function Objects
9+
10+
Built-in function objects that are not identified as constructors do not
11+
implement the [[Construct]] internal method unless otherwise specified in
12+
the description of a particular function.
13+
14+
sec-evaluatenew
15+
16+
...
17+
7. If IsConstructor(constructor) is false, throw a TypeError exception.
18+
...
19+
includes: [isConstructor.js]
20+
features: [Reflect.construct, Atomics.pause]
21+
---*/
22+
23+
assert.sameValue(isConstructor(Atomics.pause), false, 'isConstructor(Atomics.pause) must return false');
24+
25+
assert.throws(TypeError, () => {
26+
new Atomics.pause();
27+
});
28+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2024 the V8 project authors. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-atomics.pause
6+
description: Atomics.pause returns undefined
7+
features: [Atomics.pause]
8+
---*/
9+
10+
assert.sameValue(Atomics.pause(), undefined,
11+
'Atomics.pause returns undefined');
12+
13+
const values = [
14+
undefined,
15+
42,
16+
0,
17+
-0,
18+
Number.MAX_SAFE_INTEGER
19+
];
20+
21+
for (const v of values) {
22+
assert.sameValue(Atomics.pause(v), undefined,
23+
'Atomics.pause returns undefined');
24+
}

0 commit comments

Comments
 (0)